package com.zhaopin.rpc;

import com.zhaopin.jvm.OOMTest;

import java.io.Serializable;

public class User implements Serializable {
    private static final long serialVersionUID = 1L;

    private Integer id;
    private String name;

    public User(Integer id, String name) {
        this.id = id;
        this.name = name;
    }

    public User() {
    }

    //User类需要重写finalize方法
    @Override
    protected void finalize() throws Throwable {
//        OOMTest.list.add(this);
//        System.out.println("关闭资源，userid=" + id + "即将被回收");
    }

    public Integer getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", name='" + name + '\'' +
                '}';
    }
}